package com.wandian.notepad.adapter;

import android.view.View;
import android.widget.RelativeLayout;

import com.alibaba.android.arouter.launcher.ARouter;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.mylib.libcore.config.RouterConfig;
import com.mylib.libcore.utils.DateUtils;
import com.mylib.libcore.utils.JsonUtil;
import com.mylib.libcore.utils.TimeFormate;
import com.mylib.libcore.utils.TimeUtils;
import com.mylib.libcore.utils.UIUtils;
import com.wandian.notepad.R;
import com.wandian.notepad.bean.NoteBean;

/**
 * NotepadHistoryRecycleAdapter-适配器
 */
public class NotepadHistoryRecycleAdapter extends BaseQuickAdapter<NoteBean, BaseViewHolder> {

    public NotepadHistoryRecycleAdapter(int layoutResId) {
        super(layoutResId);
    }


    @Override
    protected void convert(BaseViewHolder helper, NoteBean item) {

        long lDay = DateUtils.getTimeExpend(TimeUtils.timeToMiao(UIUtils.showDataByString(item.getSetTime())), System.currentTimeMillis());
        String cc = String.valueOf(Math.abs(lDay));
        helper.setText(R.id.tv_notes_title, item.getTitle()+"")
                .setText(R.id.tv_current_date, item.getSetTime()+" "+TimeUtils.dateToWeek(item.getSetTime()))
                .setText(R.id.tv_less_day, cc+"")
                .setText(R.id.tv_tag_2, lDay > 0 ? "还有" : "已经");
        RelativeLayout rl_root = helper.getView(R.id.rl_root);
        rl_root.setOnClickListener(v -> ARouter.getInstance().build(RouterConfig.ROUTER_ACTIVITY_NOTEPAD_DETAIL).withString("notepad_item",JsonUtil.toJson(item)).navigation());

    }

}